﻿using Microsoft.AspNetCore.Mvc;
using WebApplication1.Entity;
using yunbo.Model.BIP;
using yunbo.Repositorys.FPMRepositorys;
using yunbo.Repositorys.SSMRepositorys;

namespace yunbo.Controllers.BIPControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class BD_CPController : Controller
    {
        BD_CPRepository bD_CPRepository = new BD_CPRepository();


        [HttpGet("GetBD_CP")]
        public IActionResult GetBD_CP()
        {
            List<BD_CP> quans = bD_CPRepository.GetBD_CP();
            return Ok(quans);
        }
        [HttpGet("GetBD_CPcp_code")]
        public IActionResult GetBD_CPcp_code(string cp_code)
        {
            BD_CP quans = bD_CPRepository.GetBD_CPcp_code(cp_code);
            return Ok(quans);
        }
        [HttpPut("UpdateStatus")]
        public IActionResult UpdateStatus(string cp_code, int cp_state, int update_by)
        {
            int quans = bD_CPRepository.UpdateStatus(cp_code, cp_state,update_by);
            return Ok(quans);
        }
        [HttpPut("UpdateDelete")]
        public IActionResult UpdateDelete(string cp_code, int isdelete, int update_by)
        {
            int quans = bD_CPRepository.UpdateDelete(cp_code, isdelete, update_by);
            return Ok(quans);
        }
        [HttpPut("UpdateCP")]
        public IActionResult UpdateCP(XGBD_CP cp)
        {
            int quans = bD_CPRepository.UpdateCP(cp);
            return Ok(quans);
        }
        [HttpPost("InsertCP")]
        public IActionResult InsertCP(XGBD_CP cp)
        {
            int quans = bD_CPRepository.InsertCP(cp);
            return Ok(quans);
		}
		[HttpGet("GetCPs")]
		public IActionResult GetCPs(string? codes)
		{
			List<BD_CP> cp = bD_CPRepository.GetCPs(codes);
			return Ok(cp);
		}
	}
}
